capture log close
clear
clear matrix
program drop _all


*Open log and set directory. CHANGE PATHS TO SUIT:
log using D:\Dropbox\WWL\Empirics\R&R\Replication\WuLichtWolfordISQReplication.log, replace
cd D:\Dropbox\WWL\Empirics\R&R\Replication\

*Install outreg2 package for writing tables:
net install outreg2, from(http://fmwww.bc.edu/RePEc/bocode/o)

*set scheme for graphics:
set scheme s1mono


	
*PURPOSE:	This file will replicate the analyses reported in Wu, Wolford and Licht's
*			ISQ publication, "Same as the Old Boss? Domestic Politics and the Turnover 
*			Trap". 
*AUTHOR:	Amanda A. Licht, PhD Binghamton University
*MACHINE:	LICHTBINGOFFICE, Lenovo ThinkStation running StataMP 15
*DATE:		9/3/2020
*MODIFIED:	
*FILE:		Wu Licht Wolford ISQ Replication.do
*LOG:		WuLichtWolfordISQReplication.log
*DATA:		WuWolfordLichtReplicationMainAnalysis
*OUTPUT:
*	Data/	WuLichtWolford_ObservedValuesIV.dta	-observed vals of controls @100 values of time
*			WuLichtWolfordSimulation			-1K simulations of Probabilities and marginal effects
*			WuLichtWolfordSimulationCIs			-2.5th, 5th, 50th, 95th, 97.5th percentiles 
*		Figure1.gph		- marginal effect of tenure on escalation across types
*			Figure2.gph		- conditional prob of escalation over tenure time across types
*			FigureA1.gph	- hazard ratio of autocratic challenger survival
*		Heckprobit Regime Type Interactions.txt 	- model results and combined coefficients
*			TableA2.txt									- NPH Cox of Leader Survival
*			Table A6 and A7.txt							- include Young's insecurity, bootstrapped
*			Table A8.txt								- alternative estimation samples
*			Table A10 and A11.txt						- excluding irregular entries


*open main analysis dataset:
use WuLichtWolfordReplicationMainAnalysis.dta
	

********************************************************************************
*Run main model from Table 1
********************************************************************************
#delimit ;		
heckprob escalation 	lntenday_weak 
						demXlntenday_weak
						heir_solsXlntenure_weak
						demXheir_solsXlntenure_weak
						heir_sols_weak
						demXheir_sols_weak
						dem_weak
						jointdemcont 
						weakage 
						weakprev ,  
select (cwinit=		lntenday_weak 
					demXlntenday_weak
					heir_solsXlntenure_weak
					demXheir_solsXlntenure_weak
					heir_sols_weak
					demXheir_sols_weak
					dem_weak  
					jointdemcont 
					weakage 
					weakprev  
					weakrival_l 
					distance 
					pceyrs 
					pceyrs2 
					pceyrs3) 
		cluster(ccdyad);
#delimit cr		

*****************************************************
*Combined coefficients from Initiation equation:
*****************************************************

*Effect of a nondem heir_sols turnover, over time:
di ln(1/365)
lincom [cwinit]heir_sols_weak + [cwinit]heir_solsXlntenure_weak*-5.8998974
	local CCInit_nondemhr = round(`r(estimate)', .001)
	local CCInit_nondemhrse = round(`r(se)', .001)
sum lntenday_weak
lincom [cwinit]heir_sols_weak + [cwinit]heir_solsXlntenure_weak*`r(mean)'
sum lntenday_weak
lincom [cwinit]heir_sols_weak + [cwinit]heir_solsXlntenure_weak*`r(max)'

*Effect of accumulating tenure, for nondem heir_sols:
lincom [cwinit]lntenday_weak+ [cwinit]heir_solsXlntenure_weak
	local CCInit_tnondemhr = round(`r(estimate)', .001)
	local CCInit_tnondemhrse = round(`r(se)', .001)

*Effect of a dem heir_sols turnover, over time:
lincom [cwinit]heir_sols_weak + [cwinit]demXheir_sols_weak + [cwinit]heir_solsXlntenure_weak*-5.8998974+ [cwinit]demXheir_solsXlntenure_weak*-5.8998974
	local CCInit_demhr = round(`r(estimate)', .001)
	local CCInit_demhrse = round(`r(se)', .001)
sum lntenday_weak
lincom [cwinit]heir_sols_weak +[cwinit]demXheir_sols_weak  + [cwinit]heir_solsXlntenure_weak*`r(mean)' + [cwinit]demXheir_solsXlntenure_weak*`r(mean)'
sum lntenday_weak
lincom [cwinit]heir_sols_weak +[cwinit]demXheir_sols_weak +  [cwinit]heir_solsXlntenure_weak*`r(max)' + [cwinit]demXheir_solsXlntenure_weak*`r(max)'

*Effect of accumulating tenure, for dem heir_sols:
lincom [cwinit]lntenday_weak+ [cwinit]demXlntenday_weak + [cwinit]heir_solsXlntenure_weak + [cwinit]demXheir_solsXlntenure_weak  
	local CCInit_tdemhr = round(`r(estimate)', .001)
	local CCInit_tdemhrse = round(`r(se)', .001)
	
*For nonheirs:
*Effect of tenure for dems:
lincom [cwinit]lntenday_weak+[cwinit]demXlntenday_weak
	local CCInit_tdem = round(`r(estimate)', .001)
	local CCInit_tdemse = round(`r(se)', .001)

		
sum lntenday_weak	
lincom 	[cwinit]dem_weak+[cwinit]demXlntenday_weak*`r(min)'
	local CCInit_dem = round(`r(estimate)', .001)
	local CCInit_demse = round(`r(se)', .001)
	
	
*****************************************************
*Combined coefficients from Escalation equation:
*****************************************************

*Effect of a nondem heir_sols turnover, over time:
lincom [escalation]heir_sols_weak + [escalation]heir_solsXlntenure_weak*-5.8998974
	local CCEsca_nondemhr = round(`r(estimate)', .001)
	local CCEsca_nondemhrse = round(`r(se)', .001)
sum lntenday_weak
lincom [escalation]heir_sols_weak + [escalation]heir_solsXlntenure_weak*`r(mean)'
sum lntenday_weak
lincom [escalation]heir_sols_weak + [escalation]heir_solsXlntenure_weak*`r(max)'

*Effect of accumulating tenure, for nondem heir_sols:
lincom [escalation]lntenday_weak+ [escalation]heir_solsXlntenure_weak
	local CCEsca_tnondemhr = round(`r(estimate)', .001)
	local CCEsca_tnondemhrse = round(`r(se)', .001)

*Effect of a dem heir_sols turnover, over time:
lincom [escalation]heir_sols_weak + [escalation]demXheir_sols_weak + [escalation]heir_solsXlntenure_weak*-5.8998974 + [escalation]demXheir_solsXlntenure_weak*-5.8998974
	local CCEsca_demhr = round(`r(estimate)', .001)
	local CCEsca_demhrse = round(`r(se)', .001)
sum lntenday_weak
lincom [escalation]heir_sols_weak  + [escalation]demXheir_sols_weak + [escalation]heir_solsXlntenure_weak*`r(mean)' + [escalation]demXheir_solsXlntenure_weak*`r(mean)'
sum lntenday_weak
lincom [escalation]heir_sols_weak  + [escalation]demXheir_sols_weak + [escalation]heir_solsXlntenure_weak*`r(max)' + [escalation]demXheir_solsXlntenure_weak*`r(max)'

*Effect of accumulating tenure, for dem heir_sols:
lincom [escalation]lntenday_weak+ [escalation]demXlntenday_weak + [escalation]heir_solsXlntenure_weak + [escalation]demXheir_solsXlntenure_weak  
	local CCEsca_tdemhr = round(`r(estimate)', .001)
	local CCEsca_tdemhrse = round(`r(se)', .001)

*For nonheirs:
*Effect of tenure for dems:
lincom [escalation]lntenday_weak+[escalation]demXlntenday_weak
	local CCEsca_tdem = round(`r(estimate)', .001)
	local CCEsca_tdemse = round(`r(se)', .001)
	

lincom 	[escalation]dem_weak+[escalation]demXlntenday_weak*-5.8998974
	local CCEsca_dem = round(`r(estimate)', .001)
	local CCEsca_demse = round(`r(se)', .001)

	
*Write Table with information from Table 1 and Table 2:
	#delimit ;
	outreg2 using "Heckprobit Regime Type Interactions.txt",
		dec(3) 
		replace
		addtext("Initiation Dem Tenure, `CCInit_tdem'(`CCInit_tdemse')" 
				"Escalation Dem Tenure, `CCEsca_tdem'(`CCEsca_tdemse')"
				"Initiation Dem Heir Tenure, `CCInit_tdemhr'(`CCInit_tdemhrse')" 
				"Escalation Dem Heir Tenure, `CCEsca_tdemhr'(`CCEsca_tdemhrse')"
				"Initiation Nondem Heir Tenure, `CCInit_tnondemhr'(`CCInit_tnondemhrse')" 
				"Escalation Nondem Heir Tenure, `CCEsca_tnondemhr'(`CCEsca_tnondemhrse')"
				"Initiaion Dem at Start, `CCInit_dem'(`CCInit_demse')"
				"Escalation Dem at Start, `CCEsca_dem'(`CCEsca_demse')"
				"Initiation Dem Heir at Start, `CCInit_demhr'(`CCInit_demhrse')"
				"Escalation Dem Heir at Start, `CCEsca_demhr'(`CCEsca_demhrse')"
				"Initiation Nondem Heir at Start, `CCInit_nondemhr'(`CCInit_nondemhrse')"
				"Escalation Nondem Heir at Start, `CCEsca_nondemhr'(`CCEsca_nondemhrse')");	
	#delimit cr

*Preserve matrices:
mat def b = e(b)
mat def V = e(V)
	mat list b
	
***********************************************
*Simulation to obtain predicted probabiliies:
***********************************************


*Frst, get a dataset of observed values for the simulation:
keep if e(sample)


*keep only controls:
#delimit ;
keep lntenday_weak
	jointdemcont 
	weakage 
	weakprev  
	weakrival_l 
	distance 
	pceyrs;
#delimit cr		


*Get 100 values of tenure w/observed values of covariates:
gen id=_n
expand 100

*get info about values of tenure:
sum lntenday_weak
	local tmin = `r(min)'
	local tmax = `r(max)'
bysort id: gen lnten = `tmin' if _n==1
	bysort id: replace lnten = lnten[_n-1] + ((`tmax'-`tmin')/_N) if _n>1
sum lnten
save WuLichtWolford_ObservedValuesIV.dta, replace	


clear


/*Write the program for calculating probabilities:*/
*program drop WLWinterp
program define WLWinterp
	syntax, dem(real) solsh(real)
			*syntax declares there will be scalars for dem and solsh taking real values
	clear
	set obs 1
	
	drawnorm b1-b28, means(b) cov(V)	
	
	expand 596400	/*expand by N*100 values of time*/
	
	merge 1:1 _n using WuLichtWolford_ObservedValuesIV.dta, nogen
	
	*Grab scalars from foreach loop for ease of programming below: 
	gen dem 	= `dem'
	gen solsh 	= `solsh'
	
	*Get linear indices:
	#delimit ;
	gen XBesca = b1*lnten+
				b2*dem*lnten+
				b3*solsh*lnten+
				b4*dem*solsh*lnten+
				b5*solsh+
				b6*dem*solsh+
				b7*dem+
				b8*jointdemcont +
				b9*weakage +
				b10*weakprev +
				b11*1;
							
	gen XBinit = b12*lnten+
				b13*dem*lnten+
				b14*solsh*lnten+
				b15*dem*solsh*lnten+
				b16*solsh+
				b17*dem*solsh+
				b18*dem+
				b19*jointdemcont +
				b20*weakage +
				b21*weakprev +
				b22*weakrival_l +
				b23*distance +
				b24*pceyrs +
				b25*pceyrs^2 +
				b26*pceyrs^3 +
				b27*1;
	#delimit cr
	
	*grab rho and limit to -1/+1
	gen rho = (exp(2*atanh(b28))-1)/(exp(2*atanh(b28))+1)
	
	
	*Get Combined coefficients:
	gen CCesca_lnten =  b1 + b2*dem + b3*solsh + b4*dem*solsh
	gen CCinit_lnten = b15 + b16*dem + b17*solsh + b18*dem*solsh
	
	gen CCesca_dem = b7 + b2*lnten + b4*solsh*lnten + b6*solsh
	gen CCinit_dem = b21 + b16*lnten + b18*solsh*lnten + b20*solsh
	
	gen CCesca_solsh = b5 + b3*lnten + b4*lnten*dem + b6*dem
	gen CCinit_solsh = b19 + b17*lnten + b18*dem*lnten + b20*dem
	
	*Predicted probabilities:
	gen CPesca = binormal(XBesca, XBinit, rho)/normal(XBinit)
	gen MPesca = normal(XBesca)
	gen MPinit = normal(XBinit)
	gen PDFesca = normalden(XBesca)
	gen PDFinit = normalden(XBinit)
	
	*Get Marginal effects
	gen MEesca_lnten = CCesca_lnten*PDFesca
	gen MEinit_lnten = CCinit_lnten*PDFinit
	
	gen MEesca_dem = CCesca_dem*PDFesca
	gen MEinit_dem = CCinit_dem*PDFinit
	
	gen MEesca_solsh = CCesca_solsh*PDFesca
	gen MEinit_solsh = CCinit_solsh*PDFinit
	
	*Get mean predictions @ each value of tenure across observed values of controls:
	#delimit ;
	collapse (mean) CPesca MPesca MPinit 
					MEesca_lnten MEinit_lnten
					MEesca_dem MEinit_dem
					MEesca_solsh MEinit_solsh,
					by(lnten);
	#delimit cr
	
	*restore the dem and solsh scalars
	gen dem = `dem'
	gen solsh = `solsh'
	
	*Save results
	append using WuLichtWolfordSimulation.dta
	save WuLichtWolfordSimulation.dta, replace
end

*make place to store results:
clear 
	save WuLichtWolfordSimulation.dta, replace emptyok

*Run simulations (NOTE: these simulations could take some time depending on your computing power):
set more off
foreach dem in 0 1 	{
foreach solsh in 0 1	{
		simulate, seed(90617) reps(1000): WLWinterp, dem(`dem') solsh(`solsh')
					}
					}

					
***********************************************************************
*Get Confidence intervals around simulated quantities of interest
***********************************************************************

*make a place to post them:
clear
set obs 2
gen solsh = _n-1
gen dem = solsh
	
expand 2
	replace dem = 1 if _n==3
	replace dem = 0 if _n==4

		tab solsh dem

expand 100

bysort solsh dem: gen lnten = 	-5.900582 if _n==1 
bysort solsh dem: 	replace lnten = lnten[_n-1] + ((3.346861--5.900582)/_N) if _n>1

sum lnten

save WuLichtWolfordSimulationCIs.dta, replace


*Statsby loops:
	use WuLichtWolfordSimulation.dta, clear

#delimit ;
foreach var in 	CPesca MPesca MPinit 
					MEesca_lnten MEinit_lnten
					MEesca_dem MEinit_dem
					MEesca_solsh MEinit_solsh	{;


	use WuLichtWolfordSimulation.dta, clear;
	
	statsby `var'_lo95 = r(r1) `var'_lo90=r(r2) `var'_med = r(r3) `var'_hi90 = r(r4) `var'_hi95 = r(r5),
			by(lnten dem solsh): _pctile `var', p(2.5, 5, 50, 95, 97.5); 
		#delimit cr
		
		merge 1:1 lnten dem solsh using WuLichtWolfordSimulationCIs.dta, nogen
				
		save WuLichtWolfordSimulationCIs.dta, replace

		}
		
***************
*Figures:
***************
use WuLichtWolfordSimulationCIs.dta, clear
gen tenure = exp(lnten)


/*Figure 1: Marginal Effect of tenure on escalation*/

*Make an artificial Y-axis for the scatter:
gen Yscat = 4 if dem==1&solsh==1
	replace Yscat = 3 if dem==1&solsh==0
	replace Yscat = 2 if dem==0&solsh==1
	replace Yscat = 1 if dem==0&solsh==0
	
		lab def Yscatfmt 4 "Democratic Heir" 3 "Democratic Challenger" 2 "Autocratic Heir" 1 "Autocratic Challenger"
		lab val Yscat Yscatfmt

*make a time value indicator to grab a specific value of tenure		
sort dem solsh lnten
 bysort dem solsh: gen timeval = _n

list timeval lnten tenure
		*tenure time = 3 months at timeval==50

*Graph:		
#delimit ;
twoway (rcap MEesca_lnten_lo95 MEesca_lnten_hi95 Yscat if dem==1&solsh==1&timeval==50, horiz
			blc(black))
		(scatter Yscat MEesca_lnten_med if dem==1&solsh==1&timeval==50, msym(o) mc(black))
		(rcap MEesca_lnten_lo95 MEesca_lnten_hi95 Yscat if dem==1&solsh==0&timeval==50, horiz
			blc(gs10))
		(scatter Yscat MEesca_lnten_med if dem==1&solsh==0&timeval==50, msym(o) mc(black))
		(rcap MEesca_lnten_lo95 MEesca_lnten_hi95 Yscat if dem==0&solsh==1&timeval==50, horiz
			blc(black))
		(scatter Yscat MEesca_lnten_med if dem==0&solsh==1&timeval==50, msym(d) mc(black))
		(rcap MEesca_lnten_lo95 MEesca_lnten_hi95 Yscat if dem==0&solsh==0&timeval==50, horiz
			blc(gs10))
		(scatter Yscat MEesca_lnten_med if dem==0&solsh==0&timeval==50, msym(d) mc(black)),
	ylab(1(1)4, valuelabel angle(horiz) labsi(small)) ytitle("")
	xline(0, lc(gs12) lp(vshortdash) lw(vthin))
	xtitle("Marginal Effect at 3 Months Tenure", size(medium))
	title("Marginal Effect of Tenure by Regime and Leader Type", size(medium) span)
	legend(off)
name(MEtmu, replace)	
saving("Figure1.gph", replace);
#delimit cr

/*Figure 2: Conditional probability of escalation across types*/	
foreach dem in 0 1	{
foreach solsh in 0 1	{
#delimit ;
twoway line CPesca_lo90 CPesca_lo95 CPesca_med CPesca_hi95 CPesca_hi95 tenure if dem==`dem'&solsh==`solsh',
				lc(gs11 gs8 black gs8 gs11) lp(dot dash solid dash dot)
		title("Pr(escalation|dem=`dem'&solsh=`solsh')", size(medium))
			xtitle("Years in Office", size(small))
			ytitle("Predicted Probability and CIs", size(small))
legend(off)
name(tPE_d`dem's`solsh', replace);
#delimit cr
}
}

#delimit ;
graph combine tPE_d0s0 tPE_d1s0 tPE_d0s1 tPE_d1s1, rows(2)	ycommon	
	title("Conditional Probability of Escalation by Regime Type and Heir Status", size(medium))
name(CPE, replace)
saving("Figure2.gph", replace);
#delimit cr


*********************************************************************************
*Supplemental analysis: Effect of Challenger Status on Survival
*********************************************************************************

use WuWolfordLichtReplicationSurvivalAnalysis.dta, clear

gen female = gender=="F"

*quick naive test, though we know that dem and soslchange should violate the PHA
stcox prevtimesinoffice female dem solschange, sch(sch*) sca(sca*)
estat phtest, detail
	*yep, the world makes sense for once.

*Get time interactions:	
	gen lnt = ln(sumten+1)
	gen lntXdem = lnt*dem
	gen lntXsols = lnt*solschange

	gen demXsols = dem*solschange

	gen lntXdemXsols = dem*solschange*lnt

*run NPH model:
stcox prevtimesinoffice female dem lntXdem solschange lntXsols demXsols lntXdemXsols, nohr
outreg2 using "TableA2.txt", replace dec(3) 


*Gen combined coefs to check effects over time:
sum lnt
gen Xlnt = `r(min)' in 1
	replace Xlnt = Xlnt[_n-1] + ((`r(max)' - `r(min)')/19) if _n<=20&_n>1
	sum Xlnt
	
gen CCdem = .
gen CCdem_se = .
gen CCsols = .
gen CCsols_se = .
gen CCdemXsols = .
gen CCdemXsols_se = .
gen CCsolsXdem = .
gen CCsolsXdem_se = .

			*loop of lincoms to get CC and se:
			forvalues num = 1(1)20	{
			
				local t = Xlnt in `num'
				
				*Effect of democratic heir over time:
					lincom dem+ lntXdem*`t'
						replace CCdem = `r(estimate)' in `num'
						replace CCdem_se = `r(se)' in `num'
						
				*Effect of being autocratic challenger over time:
					lincom solschange + lntXsols*`t'
						replace CCsols = `r(estimate)' in `num'
						replace CCsols_se = `r(se)' in `num'
						
				*Effect of being democratic challenger over time:
					lincom dem + lntXdem*`t' + lntXdemXsols*`t'
						replace CCdemXsols = `r(estimate)' in `num'
						replace CCdemXsols_se = `r(se)' in `num'
						
				*Effect of challenger status in democracy over time: 
					lincom solschange + lntXsols*`t'+ lntXdemXsols*`t'
						replace CCsolsXdem = `r(estimate)' in `num'
						replace CCsolsXdem_se = `r(se)' in `num'
											}
	
*Get CIs and HRs:
foreach var in 	CCdem CCsols CCdemXsols CCsolsXdem	{
	gen `var'_lo = `var' - 1.96*`var'_se
	gen `var'_hi = `var' + 1.96*`var'_se
}
foreach var in dem sols demXsols solsXdem 	{
	gen HR`var' = exp(CC`var')
	gen HR`var'_lo = exp(CC`var'_lo)
	gen HR`var'_hi = exp(CC`var'_hi)
											}
											
*Graph:
											
				*Effect of being autocratic challenger over time:
				#delimit ;
				twoway line HRsols HRsols_lo HRsols_hi Xlnt, sort lc(black gs10 gs10) lp(solid dash dash)
					yline(1, lc(gs12) lp(dot))
					xtitle("Log of Days in Office", size(small))
					ytitle("Hazard Ratio", size(small))
					title("Effect of Being Challenger on Hazard Rate in Autocracies", size(medium))
				name(sols, replace)
				legend(off)
				saving("FigureA1.gph", replace);
			
				*Effect of being democratic challenger over time:
				#delimit ;
				twoway line HRdemXsols HRdemXsols_lo HRdemXsols_hi Xlnt, sort lc(black gs10 gs10) lp(solid dash dash)
					yline(1, lc(gs12) lp(dot))
					xtitle("Log of Days in Office", size(small))
					ytitle("Hazard Ratio", size(small))
					title("Effect of Being Challenger on Hazard Rate in Democracies", size(medium))
				name(demsols, replace)
				legend(off);
				#delimit cr
				

*********************************************************************************
*Robustness Checks
*********************************************************************************

*1) Robustness to inclusion of Leader Insecurity

use WuLichtWolfordReplicationMainAnalysis.dta, clear

#delimit ;		
bootstrap, cluster(ccdyad) idcluster(newid100) rep(1000): 		
heckprob escalation 	lntenday_weak 
						demXlntenday_weak
						heir_solsXlntenure_weak
						demXheir_solsXlntenure_weak
						heir_sols_weak
						demXheir_sols_weak
						dem_weak
						jointdemcont 
						insecurity_young 
						weakage 
						weakprev ,  
select (cwinit=		lntenday_weak 
					demXlntenday_weak
					heir_solsXlntenure_weak
					demXheir_solsXlntenure_weak
					heir_sols_weak
					demXheir_sols_weak
					dem_weak  
					jointdemcont 
					insecurity_young 
					weakage 
					weakprev  
					weakrival_l 
					distance 
					pceyrs 
					pceyrs2 
					pceyrs3) 
		cluster(ccdyad);
est store JCR2;		
#delimit cr


*Effect of a nondem heir_sols turnover, over time:
di ln(1/365)
lincom [cwinit]heir_sols_weak + [cwinit]heir_solsXlntenure_weak*-5.8998974
	local CCInit_nondemhr = round(`r(estimate)', .001)
	local CCInit_nondemhrse = round(`r(se)', .001)
sum lntenday_weak
lincom [cwinit]heir_sols_weak + [cwinit]heir_solsXlntenure_weak*`r(mean)'
sum lntenday_weak
lincom [cwinit]heir_sols_weak + [cwinit]heir_solsXlntenure_weak*`r(max)'

*Effect of accumulating tenure, for nondem heir_sols:
lincom [cwinit]lntenday_weak+ [cwinit]heir_solsXlntenure_weak
	local CCInit_tnondemhr = round(`r(estimate)', .001)
	local CCInit_tnondemhrse = round(`r(se)', .001)

*Effect of a dem heir_sols turnover, over time:
lincom [cwinit]heir_sols_weak + [cwinit]demXheir_sols_weak + [cwinit]heir_solsXlntenure_weak*-5.8998974+ [cwinit]demXheir_solsXlntenure_weak*-5.8998974
	local CCInit_demhr = round(`r(estimate)', .001)
	local CCInit_demhrse = round(`r(se)', .001)
sum lntenday_weak
lincom [cwinit]heir_sols_weak +[cwinit]demXheir_sols_weak  + [cwinit]heir_solsXlntenure_weak*`r(mean)' + [cwinit]demXheir_solsXlntenure_weak*`r(mean)'
sum lntenday_weak
lincom [cwinit]heir_sols_weak +[cwinit]demXheir_sols_weak +  [cwinit]heir_solsXlntenure_weak*`r(max)' + [cwinit]demXheir_solsXlntenure_weak*`r(max)'

*Effect of accumulating tenure, for dem heir_sols:
lincom [cwinit]lntenday_weak+ [cwinit]demXlntenday_weak + [cwinit]heir_solsXlntenure_weak + [cwinit]demXheir_solsXlntenure_weak  
	local CCInit_tdemhr = round(`r(estimate)', .001)
	local CCInit_tdemhrse = round(`r(se)', .001)
	
*For nonheirs:
*Effect of tenure for dems:
lincom [cwinit]lntenday_weak+[cwinit]demXlntenday_weak
	local CCInit_tdem = round(`r(estimate)', .001)
	local CCInit_tdemse = round(`r(se)', .001)

		
sum lntenday_weak	
lincom 	[cwinit]dem_weak+[cwinit]demXlntenday_weak*`r(min)'
	local CCInit_dem = round(`r(estimate)', .001)
	local CCInit_demse = round(`r(se)', .001)
	
*quick lincoms in Escalation:

*Effect of a nondem heir_sols turnover, over time:
lincom [escalation]heir_sols_weak + [escalation]heir_solsXlntenure_weak*-5.8998974
	local CCEsca_nondemhr = round(`r(estimate)', .001)
	local CCEsca_nondemhrse = round(`r(se)', .001)
sum lntenday_weak
lincom [escalation]heir_sols_weak + [escalation]heir_solsXlntenure_weak*`r(mean)'
sum lntenday_weak
lincom [escalation]heir_sols_weak + [escalation]heir_solsXlntenure_weak*`r(max)'

*Effect of accumulating tenure, for nondem heir_sols:
lincom [escalation]lntenday_weak+ [escalation]heir_solsXlntenure_weak
	local CCEsca_tnondemhr = round(`r(estimate)', .001)
	local CCEsca_tnondemhrse = round(`r(se)', .001)

*Effect of a dem heir_sols turnover, over time:
lincom [escalation]heir_sols_weak + [escalation]demXheir_sols_weak + [escalation]heir_solsXlntenure_weak*-5.8998974 + [escalation]demXheir_solsXlntenure_weak*-5.8998974
	local CCEsca_demhr = round(`r(estimate)', .001)
	local CCEsca_demhrse = round(`r(se)', .001)
sum lntenday_weak
lincom [escalation]heir_sols_weak  + [escalation]demXheir_sols_weak + [escalation]heir_solsXlntenure_weak*`r(mean)' + [escalation]demXheir_solsXlntenure_weak*`r(mean)'
sum lntenday_weak
lincom [escalation]heir_sols_weak  + [escalation]demXheir_sols_weak + [escalation]heir_solsXlntenure_weak*`r(max)' + [escalation]demXheir_solsXlntenure_weak*`r(max)'

*Effect of accumulating tenure, for dem heir_sols:
lincom [escalation]lntenday_weak+ [escalation]demXlntenday_weak + [escalation]heir_solsXlntenure_weak + [escalation]demXheir_solsXlntenure_weak  
	local CCEsca_tdemhr = round(`r(estimate)', .001)
	local CCEsca_tdemhrse = round(`r(se)', .001)

*For nonheirs:
*Effect of tenure for dems:
lincom [escalation]lntenday_weak+[escalation]demXlntenday_weak
	local CCEsca_tdem = round(`r(estimate)', .001)
	local CCEsca_tdemse = round(`r(se)', .001)
	

lincom 	[escalation]dem_weak+[escalation]demXlntenday_weak*-5.8998974
	local CCEsca_dem = round(`r(estimate)', .001)
	local CCEsca_demse = round(`r(se)', .001)

	
*Table:
	#delimit ;
	outreg2 using "Table A6 and A7.txt",
		dec(3) 
		replace
		addtext("Initiation Dem Tenure, `CCInit_tdem'(`CCInit_tdemse')" 
				"Escalation Dem Tenure, `CCEsca_tdem'(`CCEsca_tdemse')"
				"Initiation Dem Heir Tenure, `CCInit_tdemhr'(`CCInit_tdemhrse')" 
				"Escalation Dem Heir Tenure, `CCEsca_tdemhr'(`CCEsca_tdemhrse')"
				"Initiation Nondem Heir Tenure, `CCInit_tnondemhr'(`CCInit_tnondemhrse')" 
				"Escalation Nondem Heir Tenure, `CCEsca_tnondemhr'(`CCEsca_tnondemhrse')"
				"Initiaion Dem at Start, `CCInit_dem'(`CCInit_demse')"
				"Escalation Dem at Start, `CCEsca_dem'(`CCEsca_demse')"
				"Initiation Dem Heir at Start, `CCInit_demhr'(`CCInit_demhrse')"
				"Escalation Dem Heir at Start, `CCEsca_demhr'(`CCEsca_demhrse')"
				"Initiation Nondem Heir at Start, `CCInit_nondemhr'(`CCInit_nondemhrse')"
				"Escalation Nondem Heir at Start, `CCEsca_nondemhr'(`CCEsca_nondemhrse')");	
	#delimit cr


*2) Robustness to Two Alternative Samples (Table A8)

use WuLichtWolfordReplicationAllDyadAnalysis.dta, clear

des 


tab1 pol_rel contig rivalry

*First, the model reported in our ISQ manuscript:
#delimit ;		
heckprob escalation 	lntenday_weak 
						demXlntenday_weak
						heir_solsXlntenure_weak
						demXheir_solsXlntenure_weak
						heir_sols_weak
						demXheir_sols_weak
						dem_weak
						jointdemcont 
						weakage 
						weakprev if rivalry==1,  
select (cwinit=		lntenday_weak 
					demXlntenday_weak
					heir_solsXlntenure_weak
					demXheir_solsXlntenure_weak
					heir_sols_weak
					demXheir_sols_weak
					dem_weak  
					jointdemcont 
					weakage 
					weakprev  
					weakrival_l 
					distance 
					pceyrs 
					pceyrs2 
					pceyrs3) 
		cluster(ccdyad);
#delimit cr		

*quick lincoms in Initiation:

*Effect of a nondem heir_sols turnover, over time:
di ln(1/365)
lincom [cwinit]heir_sols_weak + [cwinit]heir_solsXlntenure_weak*-5.8998974
	local CCInit_nondemhr = round(`r(estimate)', .001)
	local CCInit_nondemhrse = round(`r(se)', .001)
sum lntenday_weak
lincom [cwinit]heir_sols_weak + [cwinit]heir_solsXlntenure_weak*`r(mean)'
sum lntenday_weak
lincom [cwinit]heir_sols_weak + [cwinit]heir_solsXlntenure_weak*`r(max)'

*Effect of accumulating tenure, for nondem heir_sols:
lincom [cwinit]lntenday_weak+ [cwinit]heir_solsXlntenure_weak
	local CCInit_tnondemhr = round(`r(estimate)', .001)
	local CCInit_tnondemhrse = round(`r(se)', .001)

*Effect of a dem heir_sols turnover, over time:
lincom [cwinit]heir_sols_weak + [cwinit]demXheir_sols_weak + [cwinit]heir_solsXlntenure_weak*-5.8998974+ [cwinit]demXheir_solsXlntenure_weak*-5.8998974
	local CCInit_demhr = round(`r(estimate)', .001)
	local CCInit_demhrse = round(`r(se)', .001)
sum lntenday_weak
lincom [cwinit]heir_sols_weak +[cwinit]demXheir_sols_weak  + [cwinit]heir_solsXlntenure_weak*`r(mean)' + [cwinit]demXheir_solsXlntenure_weak*`r(mean)'
sum lntenday_weak
lincom [cwinit]heir_sols_weak +[cwinit]demXheir_sols_weak +  [cwinit]heir_solsXlntenure_weak*`r(max)' + [cwinit]demXheir_solsXlntenure_weak*`r(max)'

*Effect of accumulating tenure, for dem heir_sols:
lincom [cwinit]lntenday_weak+ [cwinit]demXlntenday_weak + [cwinit]heir_solsXlntenure_weak + [cwinit]demXheir_solsXlntenure_weak  
	local CCInit_tdemhr = round(`r(estimate)', .001)
	local CCInit_tdemhrse = round(`r(se)', .001)
	
*For nonheirs:
*Effect of tenure for dems:
lincom [cwinit]lntenday_weak+[cwinit]demXlntenday_weak
	local CCInit_tdem = round(`r(estimate)', .001)
	local CCInit_tdemse = round(`r(se)', .001)

		
sum lntenday_weak	
lincom 	[cwinit]dem_weak+[cwinit]demXlntenday_weak*`r(min)'
	local CCInit_dem = round(`r(estimate)', .001)
	local CCInit_demse = round(`r(se)', .001)
	
*quick lincoms in Escalation:

*Effect of a nondem heir_sols turnover, over time:
lincom [escalation]heir_sols_weak + [escalation]heir_solsXlntenure_weak*-5.8998974
	local CCEsca_nondemhr = round(`r(estimate)', .001)
	local CCEsca_nondemhrse = round(`r(se)', .001)
sum lntenday_weak
lincom [escalation]heir_sols_weak + [escalation]heir_solsXlntenure_weak*`r(mean)'
sum lntenday_weak
lincom [escalation]heir_sols_weak + [escalation]heir_solsXlntenure_weak*`r(max)'

*Effect of accumulating tenure, for nondem heir_sols:
lincom [escalation]lntenday_weak+ [escalation]heir_solsXlntenure_weak
	local CCEsca_tnondemhr = round(`r(estimate)', .001)
	local CCEsca_tnondemhrse = round(`r(se)', .001)

*Effect of a dem heir_sols turnover, over time:
lincom [escalation]heir_sols_weak + [escalation]demXheir_sols_weak + [escalation]heir_solsXlntenure_weak*-5.8998974 + [escalation]demXheir_solsXlntenure_weak*-5.8998974
	local CCEsca_demhr = round(`r(estimate)', .001)
	local CCEsca_demhrse = round(`r(se)', .001)
sum lntenday_weak
lincom [escalation]heir_sols_weak  + [escalation]demXheir_sols_weak + [escalation]heir_solsXlntenure_weak*`r(mean)' + [escalation]demXheir_solsXlntenure_weak*`r(mean)'
sum lntenday_weak
lincom [escalation]heir_sols_weak  + [escalation]demXheir_sols_weak + [escalation]heir_solsXlntenure_weak*`r(max)' + [escalation]demXheir_solsXlntenure_weak*`r(max)'

*Effect of accumulating tenure, for dem heir_sols:
lincom [escalation]lntenday_weak+ [escalation]demXlntenday_weak + [escalation]heir_solsXlntenure_weak + [escalation]demXheir_solsXlntenure_weak  
	local CCEsca_tdemhr = round(`r(estimate)', .001)
	local CCEsca_tdemhrse = round(`r(se)', .001)

*For nonheirs:
*Effect of tenure for dems:
lincom [escalation]lntenday_weak+[escalation]demXlntenday_weak
	local CCEsca_tdem = round(`r(estimate)', .001)
	local CCEsca_tdemse = round(`r(se)', .001)
	

lincom 	[escalation]dem_weak+[escalation]demXlntenday_weak*-5.8998974
	local CCEsca_dem = round(`r(estimate)', .001)
	local CCEsca_demse = round(`r(se)', .001)

	
*Table:
	#delimit ;
	outreg2 using "TableA8.txt",
		dec(3) 
		ctitle("Rivalry Dyads")
		replace
		addtext("Initiation Dem Tenure, `CCInit_tdem'(`CCInit_tdemse')" 
				"Escalation Dem Tenure, `CCEsca_tdem'(`CCEsca_tdemse')"
				"Initiation Dem Heir Tenure, `CCInit_tdemhr'(`CCInit_tdemhrse')" 
				"Escalation Dem Heir Tenure, `CCEsca_tdemhr'(`CCEsca_tdemhrse')"
				"Initiation Nondem Heir Tenure, `CCInit_tnondemhr'(`CCInit_tnondemhrse')" 
				"Escalation Nondem Heir Tenure, `CCEsca_tnondemhr'(`CCEsca_tnondemhrse')"
				"Initiaion Dem at Start, `CCInit_dem'(`CCInit_demse')"
				"Escalation Dem at Start, `CCEsca_dem'(`CCEsca_demse')"
				"Initiation Dem Heir at Start, `CCInit_demhr'(`CCInit_demhrse')"
				"Escalation Dem Heir at Start, `CCEsca_demhr'(`CCEsca_demhrse')"
				"Initiation Nondem Heir at Start, `CCInit_nondemhr'(`CCInit_nondemhrse')"
				"Escalation Nondem Heir at Start, `CCEsca_nondemhr'(`CCEsca_nondemhrse')");	
	#delimit cr


*Now, in contiguous dyads:
#delimit ;		
heckprob escalation 	lntenday_weak 
						demXlntenday_weak
						heir_solsXlntenure_weak
						demXheir_solsXlntenure_weak
						heir_sols_weak
						demXheir_sols_weak
						dem_weak
						jointdemcont 
						weakage 
						weakprev if contig<=2,  
select (cwinit=		lntenday_weak 
					demXlntenday_weak
					heir_solsXlntenure_weak
					demXheir_solsXlntenure_weak
					heir_sols_weak
					demXheir_sols_weak
					dem_weak  
					jointdemcont 
					weakage 
					weakprev  
					weakrival_l 
					distance 
					pceyrs 
					pceyrs2 
					pceyrs3) 
		cluster(ccdyad);
#delimit cr		

*quick lincoms in Initiation:

*Effect of a nondem heir_sols turnover, over time:
di ln(1/365)
lincom [cwinit]heir_sols_weak + [cwinit]heir_solsXlntenure_weak*-5.8998974
	local CCInit_nondemhr = round(`r(estimate)', .001)
	local CCInit_nondemhrse = round(`r(se)', .001)
sum lntenday_weak
lincom [cwinit]heir_sols_weak + [cwinit]heir_solsXlntenure_weak*`r(mean)'
sum lntenday_weak
lincom [cwinit]heir_sols_weak + [cwinit]heir_solsXlntenure_weak*`r(max)'

*Effect of accumulating tenure, for nondem heir_sols:
lincom [cwinit]lntenday_weak+ [cwinit]heir_solsXlntenure_weak
	local CCInit_tnondemhr = round(`r(estimate)', .001)
	local CCInit_tnondemhrse = round(`r(se)', .001)

*Effect of a dem heir_sols turnover, over time:
lincom [cwinit]heir_sols_weak + [cwinit]demXheir_sols_weak + [cwinit]heir_solsXlntenure_weak*-5.8998974+ [cwinit]demXheir_solsXlntenure_weak*-5.8998974
	local CCInit_demhr = round(`r(estimate)', .001)
	local CCInit_demhrse = round(`r(se)', .001)
sum lntenday_weak
lincom [cwinit]heir_sols_weak +[cwinit]demXheir_sols_weak  + [cwinit]heir_solsXlntenure_weak*`r(mean)' + [cwinit]demXheir_solsXlntenure_weak*`r(mean)'
sum lntenday_weak
lincom [cwinit]heir_sols_weak +[cwinit]demXheir_sols_weak +  [cwinit]heir_solsXlntenure_weak*`r(max)' + [cwinit]demXheir_solsXlntenure_weak*`r(max)'

*Effect of accumulating tenure, for dem heir_sols:
lincom [cwinit]lntenday_weak+ [cwinit]demXlntenday_weak + [cwinit]heir_solsXlntenure_weak + [cwinit]demXheir_solsXlntenure_weak  
	local CCInit_tdemhr = round(`r(estimate)', .001)
	local CCInit_tdemhrse = round(`r(se)', .001)
	
*For nonheirs:
*Effect of tenure for dems:
lincom [cwinit]lntenday_weak+[cwinit]demXlntenday_weak
	local CCInit_tdem = round(`r(estimate)', .001)
	local CCInit_tdemse = round(`r(se)', .001)

		
sum lntenday_weak	
lincom 	[cwinit]dem_weak+[cwinit]demXlntenday_weak*`r(min)'
	local CCInit_dem = round(`r(estimate)', .001)
	local CCInit_demse = round(`r(se)', .001)
	
*quick lincoms in Escalation:

*Effect of a nondem heir_sols turnover, over time:
lincom [escalation]heir_sols_weak + [escalation]heir_solsXlntenure_weak*-5.8998974
	local CCEsca_nondemhr = round(`r(estimate)', .001)
	local CCEsca_nondemhrse = round(`r(se)', .001)
sum lntenday_weak
lincom [escalation]heir_sols_weak + [escalation]heir_solsXlntenure_weak*`r(mean)'
sum lntenday_weak
lincom [escalation]heir_sols_weak + [escalation]heir_solsXlntenure_weak*`r(max)'

*Effect of accumulating tenure, for nondem heir_sols:
lincom [escalation]lntenday_weak+ [escalation]heir_solsXlntenure_weak
	local CCEsca_tnondemhr = round(`r(estimate)', .001)
	local CCEsca_tnondemhrse = round(`r(se)', .001)

*Effect of a dem heir_sols turnover, over time:
lincom [escalation]heir_sols_weak + [escalation]demXheir_sols_weak + [escalation]heir_solsXlntenure_weak*-5.8998974 + [escalation]demXheir_solsXlntenure_weak*-5.8998974
	local CCEsca_demhr = round(`r(estimate)', .001)
	local CCEsca_demhrse = round(`r(se)', .001)
sum lntenday_weak
lincom [escalation]heir_sols_weak  + [escalation]demXheir_sols_weak + [escalation]heir_solsXlntenure_weak*`r(mean)' + [escalation]demXheir_solsXlntenure_weak*`r(mean)'
sum lntenday_weak
lincom [escalation]heir_sols_weak  + [escalation]demXheir_sols_weak + [escalation]heir_solsXlntenure_weak*`r(max)' + [escalation]demXheir_solsXlntenure_weak*`r(max)'

*Effect of accumulating tenure, for dem heir_sols:
lincom [escalation]lntenday_weak+ [escalation]demXlntenday_weak + [escalation]heir_solsXlntenure_weak + [escalation]demXheir_solsXlntenure_weak  
	local CCEsca_tdemhr = round(`r(estimate)', .001)
	local CCEsca_tdemhrse = round(`r(se)', .001)

*For nonheirs:
*Effect of tenure for dems:
lincom [escalation]lntenday_weak+[escalation]demXlntenday_weak
	local CCEsca_tdem = round(`r(estimate)', .001)
	local CCEsca_tdemse = round(`r(se)', .001)
	

lincom 	[escalation]dem_weak+[escalation]demXlntenday_weak*-5.8998974
	local CCEsca_dem = round(`r(estimate)', .001)
	local CCEsca_demse = round(`r(se)', .001)

	
*Table:
	#delimit ;
	outreg2 using "TableA8.txt",
		dec(3) 
		ctitle("Contiguous Dyads")
		append
		addtext("Initiation Dem Tenure, `CCInit_tdem'(`CCInit_tdemse')" 
				"Escalation Dem Tenure, `CCEsca_tdem'(`CCEsca_tdemse')"
				"Initiation Dem Heir Tenure, `CCInit_tdemhr'(`CCInit_tdemhrse')" 
				"Escalation Dem Heir Tenure, `CCEsca_tdemhr'(`CCEsca_tdemhrse')"
				"Initiation Nondem Heir Tenure, `CCInit_tnondemhr'(`CCInit_tnondemhrse')" 
				"Escalation Nondem Heir Tenure, `CCEsca_tnondemhr'(`CCEsca_tnondemhrse')"
				"Initiaion Dem at Start, `CCInit_dem'(`CCInit_demse')"
				"Escalation Dem at Start, `CCEsca_dem'(`CCEsca_demse')"
				"Initiation Dem Heir at Start, `CCInit_demhr'(`CCInit_demhrse')"
				"Escalation Dem Heir at Start, `CCEsca_demhr'(`CCEsca_demhrse')"
				"Initiation Nondem Heir at Start, `CCInit_nondemhr'(`CCInit_nondemhrse')"
				"Escalation Nondem Heir at Start, `CCEsca_nondemhr'(`CCEsca_nondemhrse')");	
	#delimit cr

		
*Now in Politically-Relevant Dyads:
#delimit ;		
heckprob escalation 	lntenday_weak 
						demXlntenday_weak
						heir_solsXlntenure_weak
						demXheir_solsXlntenure_weak
						heir_sols_weak
						demXheir_sols_weak
						dem_weak
						jointdemcont 
						weakage 
						weakprev if pol_rel==1,  
select (cwinit=		lntenday_weak 
					demXlntenday_weak
					heir_solsXlntenure_weak
					demXheir_solsXlntenure_weak
					heir_sols_weak
					demXheir_sols_weak
					dem_weak  			
					jointdemcont 
					weakage 
					weakprev  
					weakrival_l 
					distance 
					pceyrs 
					pceyrs2 
					pceyrs3) 
		cluster(ccdyad);
#delimit cr		

*quick lincoms in Initiation:

*Effect of a nondem heir_sols turnover, over time:
di ln(1/365)
lincom [cwinit]heir_sols_weak + [cwinit]heir_solsXlntenure_weak*-5.8998974
	local CCInit_nondemhr = round(`r(estimate)', .001)
	local CCInit_nondemhrse = round(`r(se)', .001)
sum lntenday_weak
lincom [cwinit]heir_sols_weak + [cwinit]heir_solsXlntenure_weak*`r(mean)'
sum lntenday_weak
lincom [cwinit]heir_sols_weak + [cwinit]heir_solsXlntenure_weak*`r(max)'

*Effect of accumulating tenure, for nondem heir_sols:
lincom [cwinit]lntenday_weak+ [cwinit]heir_solsXlntenure_weak
	local CCInit_tnondemhr = round(`r(estimate)', .001)
	local CCInit_tnondemhrse = round(`r(se)', .001)

*Effect of a dem heir_sols turnover, over time:
lincom [cwinit]heir_sols_weak + [cwinit]demXheir_sols_weak + [cwinit]heir_solsXlntenure_weak*-5.8998974+ [cwinit]demXheir_solsXlntenure_weak*-5.8998974
	local CCInit_demhr = round(`r(estimate)', .001)
	local CCInit_demhrse = round(`r(se)', .001)
sum lntenday_weak
lincom [cwinit]heir_sols_weak +[cwinit]demXheir_sols_weak  + [cwinit]heir_solsXlntenure_weak*`r(mean)' + [cwinit]demXheir_solsXlntenure_weak*`r(mean)'
sum lntenday_weak
lincom [cwinit]heir_sols_weak +[cwinit]demXheir_sols_weak +  [cwinit]heir_solsXlntenure_weak*`r(max)' + [cwinit]demXheir_solsXlntenure_weak*`r(max)'

*Effect of accumulating tenure, for dem heir_sols:
lincom [cwinit]lntenday_weak+ [cwinit]demXlntenday_weak + [cwinit]heir_solsXlntenure_weak + [cwinit]demXheir_solsXlntenure_weak  
	local CCInit_tdemhr = round(`r(estimate)', .001)
	local CCInit_tdemhrse = round(`r(se)', .001)
	
*For nonheirs:
*Effect of tenure for dems:
lincom [cwinit]lntenday_weak+[cwinit]demXlntenday_weak
	local CCInit_tdem = round(`r(estimate)', .001)
	local CCInit_tdemse = round(`r(se)', .001)

		
sum lntenday_weak	
lincom 	[cwinit]dem_weak+[cwinit]demXlntenday_weak*`r(min)'
	local CCInit_dem = round(`r(estimate)', .001)
	local CCInit_demse = round(`r(se)', .001)
	
*quick lincoms in Escalation:

*Effect of a nondem heir_sols turnover, over time:
lincom [escalation]heir_sols_weak + [escalation]heir_solsXlntenure_weak*-5.8998974
	local CCEsca_nondemhr = round(`r(estimate)', .001)
	local CCEsca_nondemhrse = round(`r(se)', .001)
sum lntenday_weak
lincom [escalation]heir_sols_weak + [escalation]heir_solsXlntenure_weak*`r(mean)'
sum lntenday_weak
lincom [escalation]heir_sols_weak + [escalation]heir_solsXlntenure_weak*`r(max)'

*Effect of accumulating tenure, for nondem heir_sols:
lincom [escalation]lntenday_weak+ [escalation]heir_solsXlntenure_weak
	local CCEsca_tnondemhr = round(`r(estimate)', .001)
	local CCEsca_tnondemhrse = round(`r(se)', .001)

*Effect of a dem heir_sols turnover, over time:
lincom [escalation]heir_sols_weak + [escalation]demXheir_sols_weak + [escalation]heir_solsXlntenure_weak*-5.8998974 + [escalation]demXheir_solsXlntenure_weak*-5.8998974
	local CCEsca_demhr = round(`r(estimate)', .001)
	local CCEsca_demhrse = round(`r(se)', .001)
sum lntenday_weak
lincom [escalation]heir_sols_weak  + [escalation]demXheir_sols_weak + [escalation]heir_solsXlntenure_weak*`r(mean)' + [escalation]demXheir_solsXlntenure_weak*`r(mean)'
sum lntenday_weak
lincom [escalation]heir_sols_weak  + [escalation]demXheir_sols_weak + [escalation]heir_solsXlntenure_weak*`r(max)' + [escalation]demXheir_solsXlntenure_weak*`r(max)'

*Effect of accumulating tenure, for dem heir_sols:
lincom [escalation]lntenday_weak+ [escalation]demXlntenday_weak + [escalation]heir_solsXlntenure_weak + [escalation]demXheir_solsXlntenure_weak  
	local CCEsca_tdemhr = round(`r(estimate)', .001)
	local CCEsca_tdemhrse = round(`r(se)', .001)

*For nonheirs:
*Effect of tenure for dems:
lincom [escalation]lntenday_weak+[escalation]demXlntenday_weak
	local CCEsca_tdem = round(`r(estimate)', .001)
	local CCEsca_tdemse = round(`r(se)', .001)
	

lincom 	[escalation]dem_weak+[escalation]demXlntenday_weak*-5.8998974
	local CCEsca_dem = round(`r(estimate)', .001)
	local CCEsca_demse = round(`r(se)', .001)

	
*Table:
	#delimit ;
	outreg2 using "TableA8.txt",
		dec(3) 
		ctitle("Politically-Relevant Dyads")
		append
		addtext("Initiation Dem Tenure, `CCInit_tdem'(`CCInit_tdemse')" 
				"Escalation Dem Tenure, `CCEsca_tdem'(`CCEsca_tdemse')"
				"Initiation Dem Heir Tenure, `CCInit_tdemhr'(`CCInit_tdemhrse')" 
				"Escalation Dem Heir Tenure, `CCEsca_tdemhr'(`CCEsca_tdemhrse')"
				"Initiation Nondem Heir Tenure, `CCInit_tnondemhr'(`CCInit_tnondemhrse')" 
				"Escalation Nondem Heir Tenure, `CCEsca_tnondemhr'(`CCEsca_tnondemhrse')"
				"Initiaion Dem at Start, `CCInit_dem'(`CCInit_demse')"
				"Escalation Dem at Start, `CCEsca_dem'(`CCEsca_demse')"
				"Initiation Dem Heir at Start, `CCInit_demhr'(`CCInit_demhrse')"
				"Escalation Dem Heir at Start, `CCEsca_demhr'(`CCEsca_demhrse')"
				"Initiation Nondem Heir at Start, `CCInit_nondemhr'(`CCInit_nondemhrse')"
				"Escalation Nondem Heir at Start, `CCEsca_nondemhr'(`CCEsca_nondemhrse')");	
	#delimit cr


	
*3) Robustness to Excluding Irregular Turnovers (Tables A10 and A11)

use WuLichtWolfordReplicationMainAnalysis.dta, clear


bysort dem1: tab entry1 heir_sols1 if weaklink==1&inmainmodelsample==1
bysort dem2: tab entry2 heir_sols2 if weaklink==2&inmainmodelsample==1

*Generate weaklink regular entry variable:
gen regularentry_weak = entry1==0 if weaklink==1
	replace regularentry_weak = entry2==0 if weaklink==2
tab regularentry_weak	

bysort dem_weak: tab regularentry_weak heir_sols_weak if e(sample)==1, col

*Exclude leaders who entered irregularly from analysis:														
#delimit ;		
heckprob escalation 	lntenday_weak 
						demXlntenday_weak
						heir_solsXlntenure_weak
						demXheir_solsXlntenure_weak
						heir_sols_weak
						demXheir_sols_weak
						dem_weak
						jointdemcont 
						weakage 
						weakprev if regularentry_weak==1,  
select (cwinit=		lntenday_weak 
					demXlntenday_weak
					heir_solsXlntenure_weak
					demXheir_solsXlntenure_weak
					heir_sols_weak
					demXheir_sols_weak
					dem_weak  					
					jointdemcont 
					weakage 
					weakprev  
					weakrival_l 
					distance 
					pceyrs 
					pceyrs2 
					pceyrs3) 
		cluster(ccdyad);
#delimit cr		

*quick lincoms in Initiation:

*Effect of a nondem heir_sols turnover, over time:
di ln(1/365)
lincom [cwinit]heir_sols_weak + [cwinit]heir_solsXlntenure_weak*-5.8998974
	local CCInit_nondemhr = round(`r(estimate)', .001)
	local CCInit_nondemhrse = round(`r(se)', .001)
sum lntenday_weak
lincom [cwinit]heir_sols_weak + [cwinit]heir_solsXlntenure_weak*`r(mean)'
sum lntenday_weak
lincom [cwinit]heir_sols_weak + [cwinit]heir_solsXlntenure_weak*`r(max)'

*Effect of accumulating tenure, for nondem heir_sols:
lincom [cwinit]lntenday_weak+ [cwinit]heir_solsXlntenure_weak
	local CCInit_tnondemhr = round(`r(estimate)', .001)
	local CCInit_tnondemhrse = round(`r(se)', .001)

*Effect of a dem heir_sols turnover, over time:
lincom [cwinit]heir_sols_weak + [cwinit]demXheir_sols_weak + [cwinit]heir_solsXlntenure_weak*-5.8998974+ [cwinit]demXheir_solsXlntenure_weak*-5.8998974
	local CCInit_demhr = round(`r(estimate)', .001)
	local CCInit_demhrse = round(`r(se)', .001)
sum lntenday_weak
lincom [cwinit]heir_sols_weak +[cwinit]demXheir_sols_weak  + [cwinit]heir_solsXlntenure_weak*`r(mean)' + [cwinit]demXheir_solsXlntenure_weak*`r(mean)'
sum lntenday_weak
lincom [cwinit]heir_sols_weak +[cwinit]demXheir_sols_weak +  [cwinit]heir_solsXlntenure_weak*`r(max)' + [cwinit]demXheir_solsXlntenure_weak*`r(max)'

*Effect of accumulating tenure, for dem heir_sols:
lincom [cwinit]lntenday_weak+ [cwinit]demXlntenday_weak + [cwinit]heir_solsXlntenure_weak + [cwinit]demXheir_solsXlntenure_weak  
	local CCInit_tdemhr = round(`r(estimate)', .001)
	local CCInit_tdemhrse = round(`r(se)', .001)
	
*For nonheirs:
*Effect of tenure for dems:
lincom [cwinit]lntenday_weak+[cwinit]demXlntenday_weak
	local CCInit_tdem = round(`r(estimate)', .001)
	local CCInit_tdemse = round(`r(se)', .001)

		
sum lntenday_weak	
lincom 	[cwinit]dem_weak+[cwinit]demXlntenday_weak*`r(min)'
	local CCInit_dem = round(`r(estimate)', .001)
	local CCInit_demse = round(`r(se)', .001)
	
*quick lincoms in Escalation:

*Effect of a nondem heir_sols turnover, over time:
lincom [escalation]heir_sols_weak + [escalation]heir_solsXlntenure_weak*-5.8998974
	local CCEsca_nondemhr = round(`r(estimate)', .001)
	local CCEsca_nondemhrse = round(`r(se)', .001)
sum lntenday_weak
lincom [escalation]heir_sols_weak + [escalation]heir_solsXlntenure_weak*`r(mean)'
sum lntenday_weak
lincom [escalation]heir_sols_weak + [escalation]heir_solsXlntenure_weak*`r(max)'

*Effect of accumulating tenure, for nondem heir_sols:
lincom [escalation]lntenday_weak+ [escalation]heir_solsXlntenure_weak
	local CCEsca_tnondemhr = round(`r(estimate)', .001)
	local CCEsca_tnondemhrse = round(`r(se)', .001)

*Effect of a dem heir_sols turnover, over time:
lincom [escalation]heir_sols_weak + [escalation]demXheir_sols_weak + [escalation]heir_solsXlntenure_weak*-5.8998974 + [escalation]demXheir_solsXlntenure_weak*-5.8998974
	local CCEsca_demhr = round(`r(estimate)', .001)
	local CCEsca_demhrse = round(`r(se)', .001)
sum lntenday_weak
lincom [escalation]heir_sols_weak  + [escalation]demXheir_sols_weak + [escalation]heir_solsXlntenure_weak*`r(mean)' + [escalation]demXheir_solsXlntenure_weak*`r(mean)'
sum lntenday_weak
lincom [escalation]heir_sols_weak  + [escalation]demXheir_sols_weak + [escalation]heir_solsXlntenure_weak*`r(max)' + [escalation]demXheir_solsXlntenure_weak*`r(max)'

*Effect of accumulating tenure, for dem heir_sols:
lincom [escalation]lntenday_weak+ [escalation]demXlntenday_weak + [escalation]heir_solsXlntenure_weak + [escalation]demXheir_solsXlntenure_weak  
	local CCEsca_tdemhr = round(`r(estimate)', .001)
	local CCEsca_tdemhrse = round(`r(se)', .001)

*For nonheirs:
*Effect of tenure for dems:
lincom [escalation]lntenday_weak+[escalation]demXlntenday_weak
	local CCEsca_tdem = round(`r(estimate)', .001)
	local CCEsca_tdemse = round(`r(se)', .001)
	

lincom 	[escalation]dem_weak+[escalation]demXlntenday_weak*-5.8998974
	local CCEsca_dem = round(`r(estimate)', .001)
	local CCEsca_demse = round(`r(se)', .001)

	
*Table:
	#delimit ;
	outreg2 using "Table A10 and A11.txt",
		dec(3) 
		replace
		addtext("Initiation Dem Tenure, `CCInit_tdem'(`CCInit_tdemse')" 
				"Escalation Dem Tenure, `CCEsca_tdem'(`CCEsca_tdemse')"
				"Initiation Dem Heir Tenure, `CCInit_tdemhr'(`CCInit_tdemhrse')" 
				"Escalation Dem Heir Tenure, `CCEsca_tdemhr'(`CCEsca_tdemhrse')"
				"Initiation Nondem Heir Tenure, `CCInit_tnondemhr'(`CCInit_tnondemhrse')" 
				"Escalation Nondem Heir Tenure, `CCEsca_tnondemhr'(`CCEsca_tnondemhrse')"
				"Initiaion Dem at Start, `CCInit_dem'(`CCInit_demse')"
				"Escalation Dem at Start, `CCEsca_dem'(`CCEsca_demse')"
				"Initiation Dem Heir at Start, `CCInit_demhr'(`CCInit_demhrse')"
				"Escalation Dem Heir at Start, `CCEsca_demhr'(`CCEsca_demhrse')"
				"Initiation Nondem Heir at Start, `CCInit_nondemhr'(`CCInit_nondemhrse')"
				"Escalation Nondem Heir at Start, `CCEsca_nondemhr'(`CCEsca_nondemhrse')");	
	#delimit cr
	
log close	
